package com.stylefeng.guns.modular.system.controller;

import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.log.LogObjectHolder;
import com.stylefeng.guns.modular.small.util.ResponseCode;
import com.stylefeng.guns.modular.small.util.ResponseResultDTO;
import com.stylefeng.guns.modular.system.model.ArtificerMeansType;
import com.stylefeng.guns.modular.system.service.IArtificerMeansTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 项目分类表 控制器
 *
 * @author fengshuonan
 * @Date 2019-09-23 22:55:50
 */
@Controller
@RequestMapping("/artificerMeansType")
public class ArtificerMeansTypeController extends BaseController {

    private String PREFIX = "/system/artificerMeansType/";

    @Autowired
    private IArtificerMeansTypeService artificerMeansTypeService;

    /**
     * 跳转到项目分类表 首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "artificerMeansType.html";
    }

    /**
     * 跳转到添加项目分类表 
     */
    @RequestMapping("/artificerMeansType_add")
    public String artificerMeansTypeAdd() {
        return PREFIX + "artificerMeansType_add.html";
    }

    /**
     * 跳转到修改项目分类表 
     */
    @RequestMapping("/artificerMeansType_update/{artificerMeansTypeId}")
    public String artificerMeansTypeUpdate(@PathVariable Integer artificerMeansTypeId, Model model) {
        ArtificerMeansType artificerMeansType = artificerMeansTypeService.selectById(artificerMeansTypeId);
        model.addAttribute("item",artificerMeansType);
        LogObjectHolder.me().set(artificerMeansType);
        return PREFIX + "artificerMeansType_edit.html";
    }

    /**
     * 获取项目分类表 列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String condition) {
        return artificerMeansTypeService.selectList(null);
    }

    /**
     * 新增项目分类表 
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(ArtificerMeansType artificerMeansType) {
        artificerMeansTypeService.insert(artificerMeansType);
        return SUCCESS_TIP;
    }

    /**
     * 删除项目分类表
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer artificerMeansTypeId) {
        artificerMeansTypeService.deleteById(artificerMeansTypeId);
        return SUCCESS_TIP;
    }

    /**
     * 删除项目分类表
     */
    @RequestMapping(value = "/deleteArtMenu")
    @ResponseBody
    public Object deleteArtMenu(@RequestParam Integer artId,@RequestParam Integer businessTypeId) {
        ResponseResultDTO responseResultDTO = new ResponseResultDTO();
        artificerMeansTypeService.deleteArtMenu(artId,businessTypeId);
        responseResultDTO.setStatus(ResponseCode.SUCCESS.getCode());
        responseResultDTO.setMsg(ResponseCode.ERROR.getDesc());
        return responseResultDTO;
    }


    /**
     * 修改项目分类表 
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(ArtificerMeansType artificerMeansType) {
        artificerMeansTypeService.updateById(artificerMeansType);
        return SUCCESS_TIP;
    }

    /**
     * 项目分类表 详情
     */
    @RequestMapping(value = "/detail/{artificerMeansTypeId}")
    @ResponseBody
    public Object detail(@PathVariable("artificerMeansTypeId") Integer artificerMeansTypeId) {
        return artificerMeansTypeService.selectById(artificerMeansTypeId);
    }
    /**
     * 项目分类表 详情
     */
    @RequestMapping(value = "/searchList/{artId}")
    @ResponseBody
    public Object searchListByArtId(@PathVariable("artId") Integer artId) {
        return artificerMeansTypeService.searchListByArtId(artId);
    }

}
